package ch01;

import java.lang.reflect.Method;

/**
 * @author yang
 * @date 2024-04-02
 */
public class TestMain {
    public static void main(String[] args) throws Exception {
        Class<Student> studentClass = Student.class;
        Student zhangsan = studentClass.getConstructor().newInstance();
        Method setAge = studentClass.getMethod("setAge", int.class);
        setAge.invoke(zhangsan, 17);
        System.out.println(zhangsan.getAge());
    }
}
